//
//  AXFMessageCell.m
//  BeeQuick
//
//  Created by 王誉升 on 2016/11/19.
//  Copyright © 2016年 six_group. All rights reserved.
//

#import "AXFMessageCell.h"
#import "AXFMessageModel.h"

@interface AXFMessageCell()

@property (nonatomic,weak) UILabel *nameL;

@property (nonatomic,weak) UIButton *showBt;

@property (nonatomic,weak) UILabel *textL;

@end

@implementation AXFMessageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI
{
    UILabel *nameLabel = [[UILabel alloc]init];
    
    nameLabel.text = @"你好";
    
    [nameLabel setFont:[UIFont systemFontOfSize:15]];
    
    nameLabel.tintColor = [UIColor blackColor];
    
    [self.contentView addSubview:nameLabel];
    
    nameLabel.numberOfLines = 0;
    
    _nameL = nameLabel;
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.equalTo(self.contentView).offset(10);
        
        make.right.equalTo(self.contentView).offset(-100);
        
    }];
    
    UIButton *bt = [[UIButton alloc]init];
    
    [bt setTitle:@"显示全部" forState:UIControlStateNormal];
    
    
    bt.titleLabel.font = [UIFont systemFontOfSize:13];
    
    [bt setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    _showBt = bt;
    
    [bt addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];
    
    [self.contentView addSubview:bt];
    
    [bt mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(nameLabel);
        
//        make.top.equalTo(self.contentView).offset(10);
        
        make.left.equalTo(nameLabel.mas_right).offset(14);
        
        make.right.equalTo(self.contentView).offset(-10);
        
    }];
    
    UIView *viewLine = [[UIView alloc]init];
  
    viewLine.backgroundColor = [UIColor grayColor];
    
    [self.contentView addSubview:viewLine];
    
    [viewLine mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.height.mas_equalTo(1);
        
        make.centerY.equalTo(self.contentView.mas_centerY);
        
        make.left.equalTo(nameLabel);
        
        make.right.equalTo(bt.mas_right);
        
    }];
    
    UILabel *underLabel = [[UILabel alloc]init];
    
    underLabel.text = @"你好";

    underLabel.font = [UIFont systemFontOfSize:12];
    
    underLabel.textColor = [UIColor grayColor];
    
    [self.contentView addSubview:underLabel];
    
    underLabel.numberOfLines = 0;
    
    _textL = underLabel;
    
    [underLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
//        make.top.equalTo(viewLine.mas_bottom).offset(10);
        
        make.left.equalTo(viewLine);
        
        make.right.equalTo(self.contentView).offset(-10);
        
        make.bottom.equalTo(self.contentView).offset(-10);
        
    }];
    
}

- (void)clickBtn
{
    
}

- (void)setModel:(AXFMessageModel *)model
{
    _model = model;
    self.nameL.text = model.name;
    [self.showBt setTitle:model.show forState:UIControlStateNormal];
    self.textL.text = model.text;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
